//
//  ProfileViewController.m
//  AILove
//
//  Created by 甘世清 on 2023/12/29.
//

#import "ProfileViewController.h"
#import "ProfileTopView.h"
#import "VipViewController.h"
#import "ZSModel.h"
#import "VipPopView.h"
#import "ChatViewController.h"
@interface ProfileViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic , strong) ProfileTopView * topView;
@end

@implementation ProfileViewController
- (void)SQ_viewWillAppear:(BOOL)animated{
    [self SQ_Header];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navLeftBtn.backgroundColor = SQHexColor(@"#999999", 0.1);
    // Do any additional setup after loading the view.
}
 
- (void)SQ_UIViewForSelfView{
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableHeaderView = self.topView;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [self SQ_tableViewAddRefresh];
    
    WS(weakSelf);
    [self.topView.messageBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf SQ_messageButtonClick];
    }];
   
}
- (void)SQ_Header{
     self.topView.model = self.model;
    [self.tableView.mj_header endRefreshing];
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:self.model.userId forKey:@"roleId"];
    [dic setObject:@"1" forKey:@"current"];
       [dic setObject:@"50" forKey:@"size"];
    [HttpTool post:Url15 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        NSDictionary * data = [[NSDictionary alloc]initWithDictionary:httpModel.data];
         NSArray * array = [ZSModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"records"]];
        self.model.photoArray = [[NSMutableArray alloc]initWithArray:array];
        self.topView.model = self.model;
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        
    }];
}
- (void)SQ_Foother{
    [self.tableView.mj_footer endRefreshing];
}
-(void)SQ_messageButtonClick{
    
        NSDictionary * dic = @{
            @"roleId":_model.userId,
        };
        [HttpTool post:KSLT paramDic:[NSMutableDictionary dictionaryWithDictionary:dic] successBlock:^(BaseModel * _Nonnull httpModel) {
            NSDictionary * dic = httpModel.data;
            ChatViewController * vc = [ChatViewController new];
            vc.roomID = dic[@"roomId"];
            vc.photoURL = self.model.cover;
            vc.title = self.model.name;
            [self.navigationController pushViewController:vc animated:YES];
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            
        }];
    
       
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  0;
}
 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"UITableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
     return  0;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
}


- (ProfileTopView *)topView{
    if (!_topView) {
        _topView = [[ProfileTopView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, 1312)];
    }
    return _topView;
}


@end
